<template>
    <el-select v-model="value7" placeholder="请选择城市" @change="choseCity">
      <el-option-group
        v-for="group in options3"
        :key="group.label"
        :label="group.label">
        <el-option
          v-for="item in group.options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-option-group>
    </el-select>
  </template>
  
  <script>
    export default {
      data() {
        return {
          options3: [{
            label: '热门城市',
            options: [{
              value: '上海',
              label: '上海'
            }, {
              value: '北京',
              label: '北京'
            }]
          }, {
            label: '城市名',
            options: [
            {
              value: '成都',
              label: '成都'
            }, {
              value: '深圳',
              label: '深圳'
            }, {
              value: '广州',
              label: '广州'
            }, {
              value: '杭州',
              label: '杭州'
            },{
              value: '武汉',
              label: '武汉'
            },
            {
              value: '西安',
              label: '西安'
            }]
          }],
          value7: ''
        }
      },
      methods:{
        // 获取到选择的城市数据
        choseCity(newValue){
          console.log(newValue)
 const chosecity= newValue
 this.$emit('ChoseCity',chosecity)
 console.log('子组件传递的',chosecity)
        }
      }
    }
  </script>
  <style scoped>
.el-select{
  /* border: red 1px solid; */
  width: 160px;
  height: 40px;
  margin-left: 150px;
  top: -30px;
}
</style>